package com.hebeu.gfh.service.impl;

import com.hebeu.gfh.mapper.MajorMapper;
import com.hebeu.gfh.mapper.UserMapper;
import com.hebeu.gfh.pojo.po.Major;
import com.hebeu.gfh.pojo.po.User;
import com.hebeu.gfh.pojo.vo.findMajor;
import com.hebeu.gfh.service.majorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 刘剑利
 * @Version: v1.0
 */
@Service("majorService")
public class majorServiceImpl implements majorService {
    @Autowired
    MajorMapper majorMapper;
    //根据学院id查询专业
    public List<Major> findMajorByCoolegeId(int collegeId){
        List<Major> majorList = majorMapper.findMajorByCoolegeId(collegeId);
        return majorList;
    }
    //添加专业
    public void addMajor(Major major){
        majorMapper.addMajor(major);
    }
    //删除专业
    public void deleteMajor(int collegeId){
        majorMapper.deleteMajor(collegeId);
    }
    //根据id查询专业
    public Major findMajorById(int majorId){
        Major major = majorMapper.findMajorById(majorId);
        return major;
    }
    //查询专业下所有学生
    public List<User> majorMember(int majorId){
        List<User> userList = majorMapper.majorMember(majorId);
        return userList;
    }
    //修改专业
    public void updateMajor(Major major){
        majorMapper.updateMajor(major);
    }

    @Override
    public List<Major> getMajorByCollegeId(findMajor findMajor) {
        List<Major> majorList = majorMapper.getMajorByCollegeId(findMajor);
        return majorList;
    }
}
